package com.fsoft.tinhcd.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@Entity
@Table(name = "COUNTRIES")
@XmlRootElement(name = "COUNTRIES")
// if declate annotation in field, enable this Annotaion.
// @XmlAccessorType(XmlAccessType.FIELD)
// Maps a class or an enum type to a XML Schema type.
@XmlType(propOrder = { "countryId", "countryName", "region" })
public class Country {
	private String countryId;
	private String countryName;
	private Region region;

	public Country() {
		// super();
	}

	@Id
	@Column(name = "COUNTRY_ID")
	@XmlElement(name = "COUNTRY_ID")
	public String getCountryId() {
		return countryId;
	}

	public void setCountryId(String countryId) {
		this.countryId = countryId;
	}

	@Column(name = "COUNTRY_NAME")
	@XmlElement(name = "COUNTRY_NAME")
	public String getCountryName() {
		return countryName;
	}

	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}

	@ManyToOne
	@JoinColumn(name = "REGION_ID", referencedColumnName = "REGION_ID")
	@XmlElement(name = "REGION_ID")
	@XmlIDREF
	public Region getRegion() {
		return region;
	}

	public void setRegion(Region region) {
		this.region = region;
	}

}
